package com.bee.plus.gpt;

import cn.hutool.http.HttpRequest;
import com.bee.plus.gpt.constant.ChatApiConstant;
import com.bee.plus.dto.ContentReq;
import com.bee.plus.dto.MessageReq;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xupei
 */
public class ChatGPTAI {


    public static void main(String[] args) {


        ContentReq contentReq1=new ContentReq();

        contentReq1.setRole("system");
        contentReq1.setContent("You are a helpful assistant.");

        ContentReq contentReq=new ContentReq();

        contentReq.setRole("user");
        contentReq.setContent("Hello");

        List list=new ArrayList<ContentReq>();
        list.add(contentReq);


        MessageReq messageReq= MessageReq.builder().model("gpt-3.5-turbo").messages(list).build();

        System.out.println(messageReq.toString());

        String data=HttpRequest.post(ChatApiConstant.url)
                .header("Content-Type","application/json")
                .header("Authorization", "Bearer "+ChatApiConstant.token)
                .body(messageReq.toString())
                .execute()
                .body();

        System.out.println(data);
    }
}
